<?php
class pk_feed extends BaseModel implements Retrievable {

	var $feedsite;
	var $title;
	var $link;
	var $content;
	 	
    public function pk_feed($values) {
        parent::__construct($values);
    }

    public function validate() {
        $errors = Array();
		return (count($errors) === 0 ? true : $errors);
    }

    public static function get($id, $primaryKey='id') {
        return parent::get($id, __CLASS__, $primaryKey);
    }
    
    public static function getAll($searchArray=Array(), $sortArray=Array()) {
        return parent::getAll($searchArray, $sortArray, __CLASS__);
    }
    
    public static function getNewsFeeds($sport) {
    	$feedSites = pk_feedsite::getFeeds($sport);
    	$feedSitesArr = array();
    	foreach($feedSites as $_feed) {
    		$feedSitesArr[] = $_feed->id;
    	}
    	$feedSitesIds = implode(",", $feedSitesArr);
    	if($feedSitesIds) {
			$query = "SELECT * FROM pk_feed WHERE feedsite IN ($feedSitesIds) ORDER BY id DESC LIMIT 10";
			return BaseModel::getByQuery($query, __CLASS__);
    	}
    }
    
}
?>